package com.caine.jvm.ch01;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;

/**
 * JVM OPTION
 * -Xmx10M -Xms10M -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps
 */
public class Test01 {
    public static void main(String[] args) {
        List<Long> list = new ArrayList<>();
        WeakReference<List<Long>> weakReference = new WeakReference<>(list);
        for (; ; ) {
            List<Long> lst = weakReference.get();
            if (lst != null) {
                lst.add(System.currentTimeMillis());
            }else{
                System.out.println("被回收了,不存了");
                System.exit(1);
            }
        }
    }
}
